<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/10/10
 * Time: 17:19
 */
function TBD_upload($file){
    //TODO: 用户登录检测

    /* 返回标准数据 */
    // $return  = array('status' => 1, 'info' => '上传成功', 'data' => '失败');

    /* 调用文件上传组件上传文件 */

    if($file['error']==0){
        $path="/Uploads/Download/".date('Y-m-d');
        if(!is_dir($_SERVER['DOCUMENT_ROOT'].$path)){

            mkdir($_SERVER['DOCUMENT_ROOT'].$path);
        }

        $hz=explode('/',$file['type']);
        $hz='.'.array_pop($hz);
        $name=$path.'/'.time().rand(1000,9999).$hz;
//            $name=$path.'/'.$file['name'];
        if(move_uploaded_file($file['tmp_name'],$_SERVER['DOCUMENT_ROOT'].$name)){
//                $return['data']=$name;
            return $name;
            //return json_encode($return);
        }
    }
    return false;
//        return json_encode($return);
}
//var_dump($_FILES);exit;
$arr=TBD_upload($_FILES['imageName']);
